package com.gitee.feizns.quickstart.dict;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.gitee.feizns.quickstart.jackson.JsonUtils;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

/**
 * @author feizns
 * @since 2025/8/22
 */
@Getter
@RequiredArgsConstructor
public class EntryImpl implements Entry {

    /**
     * 钥匙
     */
    private final String key;

    /**
     * 值
     */
    private final Object value;

    /**
     * 许可
     */
    private final Permission permission;

    /**
     * 条目
     * @param key 键
     * @param value 值
     * @return {@link Entry}
     */
    @JsonCreator
    public static Entry of(@JsonProperty("key") String key,
                           @JsonProperty("value") Object value,
                           @JsonProperty("permission") Permission permission) {
        return new EntryImpl(key, value, permission);
    }

    /**
     * to 字符串
     * @return {@link String }
     */
    @Override
    public String toString() {
        return "Entry(" + JsonUtils.toJson(this) + ")";
    }

}
